#pragma once
#include "test.h"
#include "algebra.h"
#include "algebra.cpp"

namespace krryn{
namespace algebra_tests{
	using namespace krryn;

	simple_test_case("My first test case");

	ttv case_t::test<1>(){ n("Cosine tests");
		assert_equals(math::cos(0), 1, "cos(0) == 1");
	}

	ttv case_t::test<2>(){ n("Sine tests");
		assert_equals(math::sin(0), 0, "sin(0) == 0");
		fail("this should fail hard");
	}

	ttv case_t::test<3>(){ n("Degree to radian conversion");
		assert_equals(math::degree_to_radian(180), math::PI, "180 degrees == pi rad");
		assert_equals(math::degree_to_radian(360), 2 * math::PI, "360 degrees == 2 pi rad");
		assert_equals(math::degree_to_radian(0), 0, "0 degree == 0 rad");
	}

	ttv case_t::test<4>(){ n("Floor");
		assert_equals(math::floor(3.5f), 3, "floor(3.5) == 3");
		assert_equals(math::floor(3.2f), 3, "floor(3.2) == 3");
		assert_equals(math::floor(3.7f), 3, "floor(3.7) == 3");
		assert_equals(math::floor(-3.7f), -4, "floor(-3.7) == -4");
		assert_equals(math::floor(-3.2f), -4, "floor(-3.2) == -4");
	}

	ttv case_t::test<5>(){ n("Round to integer");
		assert_equals(math::round(4.2f), 4, "round(4.2) == 4");
		assert_equals(math::round(4.5f), 5, "round(4.5) == 5");
		assert_equals(math::round(4.7f), 5, "round(4.7) == 5");
		assert_equals(math::round(-4.7f), -5, "round(-4.7) == -5");
		assert_equals(math::round(-4.2f), -4, "round(-4.2) == -4");
	}

	ttv case_t::test<6>(){ n("Absolute value");
		assert_equals(math::abs(-10), 10, "abs(-10) == 10");
		assert_equals(math::abs(10), 10, "abs(10) == 10");
	}

	ttv case_t::test<7>(){ n("Square root");
		assert_equals(math::sqrt(16.f), 4.f, "sqrt(16) == 4");
		assert_not_equals(math::sqrt(-16.f), 4.f, "sqrt(-16) != 4");
	}

	ttv case_t::test<8>(){ n("Logarithm");
		assert_equals(math::log(128, 2), 7, "2_log(128) == 7");
		assert_equals(math::log(9, 3), 2, "3_log(9) == 3");
		assert_equals(math::log(1, 10), 0, "10_log(1) == 0");
		assert_equals(math::log(10, 10), 1, "10_log(10) == 1");
	}
}
}